  var app_base_url="http://localhost/prime-school/index.php?/";
//var app_base_url="http://www.techno-bd.com/onlineresult/index.php?/";
  
  
  function DelayFuncMethod()
  {
    document.getElementById("blockDim").style.display="none";
  }
  
  function ShowHideBlockMethod(blockHide, blockShow)
  {
   var browserCheck=(document.all) ? 1 : 0;
 	var offSetWidth=0;
 	var offSetLeft=0;
 	if(browserCheck>0)
 	{ 
 	  offSetWidth=14;
 	  offSetLeft=4;  
 	}
 	var h=document.getElementById(blockHide).offsetHeight;
 	var w=document.getElementById(blockHide).offsetWidth+offSetWidth;
 	var element=document.getElementById(blockHide);
 	var left=0;var top=0;
 	if(element.offsetParent)
 	 {
 	  while(element)
 	  {
 	    left+=element.offsetLeft;
 		top+=element.offsetTop;
 		element=element.offsetParent;
 	  }
 	 }
 	   document.getElementById(blockShow).style.height=h+"px";
 	   document.getElementById(blockShow).style.width=w-12+"px";
 	   document.getElementById(blockShow).style.zIndex=50001;
 	   document.getElementById(blockShow).style.display="block";
 	   //document.getElementById(blockHide).style.display="none";
 	   var tmp1=document.getElementById(blockShow).style;
 	   tmp1.left=left-5+offSetLeft+"px";
 	   tmp1.top=top+"px";
 	   document.getElementById("imagePosition").style.paddingTop=h/2-25+"px"; 
 	
  }
  
  function isRollKey(KEYCODE)
  {
	  
   if(KEYCODE==13)
   {
	   load_html_std_marks_view_update();
   }
  }
  
  function load_html_std_marks_view_update()
   { 
	  if(document.getElementById('exam_name').value!=''&&document.getElementById('student_id').value!='')
		  {
		     var form_data={
		    		 exam_name: document.getElementById('exam_name').value,
		    		 student_id:document.getElementById('student_id').value,
		    		 academic_session: document.getElementById('academic_session').value
		           };
		     
			  var request=$.ajax({
			        type: 'POST',
			        url: app_base_url+'admin/student/load_html_std_marks_view',
			        //data: $(this).serialize(),
			        data: form_data,
			        dataType: 'html'
			       });
		
				request.done(function(data) {
					   if(data!="")
					   {
						   if(document.getElementById('exam_name').value=="first_term")
							   {
						        document.getElementById("first_term_html").innerHTML =data;
						        document.getElementById("pro_test_html").innerHTML="";
						        document.getElementById("pre_test_html").innerHTML ="";
						        document.getElementById("test_exam_html").innerHTML ="";
							   }
						   if(document.getElementById('exam_name').value=="pro_test")
							   {
							    document.getElementById("first_term_html").innerHTML ="";
						        document.getElementById("pro_test_html").innerHTML=data;
						        document.getElementById("pre_test_html").innerHTML ="";
						        document.getElementById("test_exam_html").innerHTML ="";
							   }
						   if(document.getElementById('exam_name').value=="pre_test")
							   {
							   document.getElementById("first_term_html").innerHTML ="";
						        document.getElementById("pro_test_html").innerHTML="";
						        document.getElementById("pre_test_html").innerHTML =data;
						        document.getElementById("test_exam_html").innerHTML ="";
							   }
						   if(document.getElementById('exam_name').value=="test_exam")
							   {
							    document.getElementById("first_term_html").innerHTML ="";
						        document.getElementById("pro_test_html").innerHTML="";
						        document.getElementById("pre_test_html").innerHTML ="";
						        document.getElementById("test_exam_html").innerHTML =data;
							   }
					   }
				});
				
				request.fail(function(jqXHR, textStatus) {
				    alert( "Request failed: " + textStatus );
				});
		  }
   }
  ///////////////////////////////////////
   function is_group_id_change()
   {
	   if(document.getElementById('group_id').value!='')
		  {
		     var form_data={
		    		 group_id: document.getElementById('group_id').value
		           };
		     
			  var request=$.ajax({
			        type: 'POST',
			        url: app_base_url+'admin/student/load_html_total_exam_marks_view',
			        //data: $(this).serialize(),
			        data: form_data,
			        dataType: 'html'
			       });
		
				request.done(function(data) {
					   if(data!="")
					   {
						  document.getElementById("subj_total_exam_marsk_html").innerHTML =data;
					   }
				});
				
				request.fail(function(jqXHR, textStatus) {
				    alert( "Request failed: " + textStatus );
				});
		  }
	   else
		   {
		   document.getElementById("subj_total_exam_marsk_html").innerHTML ="";
		   }
   }
  ////////////////////////////////////
  function call_resutl_process()
	  { 
				  var blockHide="result_process";
			      var blockShow="blockDim";
			      ShowHideBlock(blockHide,blockShow);
      
	              var formData = {
	            		          academic_session:document.getElementById('academic_session').value ,
	            		          group_id:document.getElementById('group_id').value ,
	            		          exam_name: document.getElementById('exam_name').value 
		                          };
				  var request=$.ajax({
				        type: 'POST',
				        url: app_base_url+'admin/student/result_process',
				        //data: $(this).serialize(),
				        data: formData,
				        dataType: 'json'
				       });
			
					request.done(function(data_json) {
						 if(data_json!="")
						   {
			                    $("#loading").html(data_json.msg);
			                    window.setTimeout("DelayFuncMethod()",2000);
						   }
					});
					
					request.fail(function(jqXHR, textStatus) {
					    alert( "Request failed: " + textStatus );
					});
	  }
	  
 /////////////////////////////////////////////////
	function send_std_assign_core_subject()
	{
		var academic_session=document.getElementById('academic_session').value;
		var url=app_base_url+"admin/student/std_assign_core_subject?academic_session="+academic_session;
		 window.location.assign(url);
	}
 ///////////////////////////////////////////////////
////////////////////////////////////
	  function call_assign_core_subject()
		  { 
					  var blockHide="core_subject_html";
				      var blockShow="blockDim";
				      ShowHideBlock(blockHide,blockShow);
	      
		              var formData = {
		            		        academic_session:document.getElementById('academic_session').value 
		                            };
					  var request=$.ajax({
					        type: 'POST',
					        url: app_base_url+'admin/student/store_std_core_subject',
					        data: formData,
					        dataType: 'json'
					       });
				
						request.done(function(data_json) {
							 if(data_json!="")
							   {
				                    $("#loading").html(data_json.msg);
				                    window.setTimeout("DelayFuncMethod()",2000);
							   }
						});
						
						request.fail(function(jqXHR, textStatus) {
						    alert( "Request failed: " + textStatus );
						});
		  }
		  
	  /////////////////////////////////////////////////
	  function send_std_assign_optional_subject()
	  { 
		 var academic_session=document.getElementById('academic_session').value;
		 var url=app_base_url+"admin/student/std_assign_optional_subject?academic_session="+academic_session;
	     window.location.assign(url);
	  }
	  
	function insert_std_assign_optional_core_subject()
	   {
	     var blockHide="opt_subject_html";
	      var blockShow="blockDim";
	      ShowHideBlock(blockHide,blockShow);

         var formData = {
       		            academic_session: document.getElementById('academic_session').value,
                        group_id: document.getElementById('group_id').value,
        	            subject_id: document.getElementById('subject_id').value,
        	            subject_type: document.getElementById('subject_type').value,
        	            area_student_id: document.getElementById('area_student_id').value
                       };
		  var request=$.ajax({
		        type: 'POST',
		        url: app_base_url+'admin/student/store_std_optional_or_core_subject',
		        data: formData,
		        dataType: 'json'
		       });
	
			request.done(function(data_json) {
				 if(data_json!="")
				   {
	                    $("#loading").html(data_json.msg);
	                    window.setTimeout("DelayFuncMethod()",2000);
				   }
			});
			
			request.fail(function(jqXHR, textStatus) {
			    alert( "Request failed: " + textStatus );
			});
			
	  }
	  ////////////////////////////////////////////////
	  function check_std_assign_noof_subject()
	  { 
	              var formData = {
	            		         academic_session:document.getElementById('academic_session').value 
	                            };
				  var request=$.ajax({
				        type: 'POST',
				        url: app_base_url+'admin/student/check_no_of_subject',
				        data: formData,
				        dataType: 'json'
				       });
			
					request.done(function(data_json) {
						 if(data_json!="")
						   {
							 $("#check_list_report").html(data_json.msg);
						   }
					});
					
					request.fail(function(jqXHR, textStatus) {
					    alert( "Request failed: " + textStatus );
					});
	  }
	  ///////////////////////////////////////////////////////
	  /////////////////////////////////////////////////
	  function go_individual_student_subject_view()
	  { 
		 var url=app_base_url+"admin/student/individual_student_subject_view";
	     window.location.assign(url);
	  }
////////////////////////////////////////////////
	  function show_subjects()
	  { 
	              var formData = {
	            		         academic_session:document.getElementById('academic_session').value,
	            		         student_id:document.getElementById('student_id').value,
	            		         group_id:document.getElementById('group_id').value
	                            };
	              
				  var request=$.ajax({
				        type: 'POST',
				        url: app_base_url+'admin/student/show_subjects',
				        data: formData,
				        dataType: 'json'
				       });
			
					request.done(function(data_json) {
						 if(data_json!="")
						   {
							 $("#std_subjects_list").html(data_json.msg);
						   }
					});
					
					request.fail(function(jqXHR, textStatus) {
					    alert( "Request failed: " + textStatus );
					});
	  }
	 /////////////////////////////////////////////////
	function generateDetailReportCard()
	{
		var blockHide="detail_card_view";
	      var blockShow="blockDim";
	      ShowHideBlock(blockHide,blockShow);
	      $("#loading").html("Generating Reports.......");
        var formData = {
      		           academic_session:document.getElementById('academic_session').value ,
      		           group_id : document.getElementById("group_id").value,
      		           from : document.getElementById("from_student_id").value,
      		           to : document.getElementById("to_student_id").value,
      		           student_id : document.getElementById("student_id").value
                      };
		  var request=$.ajax({
		        type: 'POST',
		        url: app_base_url+'admin/reports/result_card_detail_pdf_limit',
		        data: formData,
		        dataType: 'json'
		       });
	
			request.done(function() {
				 window.setTimeout("DelayFuncMethod()",2000);
				window.location=app_base_url+"admin/reports/download_report";
			});
			
			request.fail(function(jqXHR, textStatus) {
			    //alert( "Request failed: " + textStatus );
			});
	}
	 /////////////////////////////////////////////////
	function generatePermanentRecordCard()
	{
		var blockHide="record_card_view";
	      var blockShow="blockDim";
	      ShowHideBlock(blockHide,blockShow);
	      $("#loading").html("Generating Reports.......");
        var formData = {
      		           academic_session:document.getElementById('academic_session').value ,
      		           group_id : document.getElementById("group_id").value,
      		           from : document.getElementById("from_student_id").value,
      		           to : document.getElementById("to_student_id").value,
      		           student_id : document.getElementById("student_id").value
                      };
		  var request=$.ajax({
		        type: 'POST',
		        url: app_base_url+'admin/reports/std_general_info_report',
		        data: formData,
		        dataType: 'json'
		       });
	
			request.done(function() {
				 window.setTimeout("DelayFuncMethod()",2000);
				window.location=app_base_url+"admin/reports/download_report";
			});
			
			request.fail(function(jqXHR, textStatus) {
			    //alert( "Request failed: " + textStatus );
			});
	}
	//////////////////////////////////////////
	
	function download_masterResult_excel()
	{
		 var academic_session=document.getElementById('academic_session').value;
		 var group_id=document.getElementById('group_id').value;
		 var exam_name=document.getElementById('exam_name').value;
		 var url=app_base_url+"admin/reports/result_excel_report?academic_session="+academic_session+"&group_id="+group_id+"&exam_name="+exam_name;
	     window.location.assign(url);
	}
	
///////////////////////////////////////
	   function attence_exam_change()
	   {
		   if(document.getElementById('group_id').value!='')
			  {
			     var form_data={
			    		 academic_session: document.getElementById('academic_session').value,
			    		 group_id: document.getElementById('group_id').value,
			    		 section: document.getElementById('section').value,
			    		 subject_id: document.getElementById('subject_id').value,
			    		 exam_name: document.getElementById('exam_name').value
			           };
			     
				  var request=$.ajax({
				        type: 'POST',
				        url: app_base_url+'admin/student/subject_total_attendence_sel',
				        //data: $(this).serialize(),
				        data: form_data,
				        dataType: 'json'
				       });
			
					request.done(function(data_json) {
						 if(data_json!="")
						   {
							 $("#no_of_class").val(data_json.msg);
						   }
					});
					
					request.fail(function(jqXHR, textStatus) {
					    alert( "Request failed: " + textStatus );
					});
			  }
		   else
			   {
			   document.getElementById("no_of_class").value ="";
			   }
	   }
	   
///////////////////////////////////////////////////////////
	   function show_all_attendence()
	   {
		   if(document.getElementById('group_id').value!='')
			  {
			     var form_data={
			    		 academic_session: document.getElementById('academic_session').value,
			    		 group_id: document.getElementById('group_id').value,
			    		 section: document.getElementById('section').value,
			    		 subject_id: document.getElementById('subject_id').value,
			    		 exam_name: document.getElementById('exam_name').value
			           };
			     
				  var request=$.ajax({
				        type: 'POST',
				        url: app_base_url+'admin/student/show_all_attendence',
				        //data: $(this).serialize(),
				        data: form_data,
				        dataType: 'html'
				       });
			
				  request.done(function(data) {
					   if(data!="")
					   {
						  document.getElementById("attendence_div").innerHTML =data;
					   }
				});
				
				request.fail(function(jqXHR, textStatus) {
				    alert( "Request failed: " + textStatus );
				});
		  }
	    else
		   {
	    	alert("Select Session and Group.. ");
		    document.getElementById("attendence_div").innerHTML ="";
		   }
	   }
//////////////////////////////////////////////////////////
	   function download_emp_attendence_pdf()
	   {
			     var form_data={
			    		 start_date: document.getElementById('start_date').value,
			    		 end_date: document.getElementById('end_date').value,
			    		 dept_id: document.getElementById('dept_id').value,
			    		 search_string: document.getElementById('search_string').value,
			    		 order: document.getElementById('order').value
			           };
			     
				  var request=$.ajax({
				        type: 'POST',
				        url: app_base_url+'admin/reports/emp_attendence_report',
				        //data: $(this).serialize(),
				        data: form_data,
				        dataType : 'json'
				        //dataType : 'text',
				        //contentType : 'application/pdf'
				       });
			
				  request.done(function(data) {
					   if(data!="")
					   { //alert(PdfURL+data.msg);
					   //window.location=PdfURL+data.msg;
					   window.open(PdfURL+data.msg); 
						  // var iframe = $('<iframe>');
				           // iframe.attr('src','/pdf/allCards.pdf?options=first&second=here');
				           // $('#targetDiv').append(iframe);
					   }
				});
				
				request.fail(function(jqXHR, textStatus) {
				    alert( "Request failed: " + textStatus );
				});

	   }
//////////////////////////////////////////////////////////